﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ComponentFactory.Krypton.Toolkit;
using WeifenLuo.WinFormsUI.Docking;
namespace XenoStudio
{
    public partial class PlatoIDE : KryptonForm
    {

        public static SceneExplorer FormSceneExplorer { get; set; }
        public static ProjectExplorer FormProjectExplorer { get; set; }
        public static Messages FormMessages { get; set; }
        public static SceneEditor FormSceneEditor { get; set; }
        public PlatoIDE()
        {
            InitializeComponent();
        }

        private void PlatoIDE_Load(object sender, EventArgs e)
        {
            FormSceneExplorer = new SceneExplorer();
            FormProjectExplorer = new ProjectExplorer();
            FormMessages = new Messages();
            FormSceneEditor = new SceneEditor();


            if (System.IO.File.Exists("GuiLayout.xml"))
            {
                DeserializeDockContent dc = new DeserializeDockContent(GetDockWindow);
                DockPane.LoadFromXml("GuiLayout.xml", dc);
            }
            else
            {
                FormSceneEditor.Show(DockPane, DockState.Document);
                FormMessages.Show(DockPane, DockState.DockBottom);
                FormSceneExplorer.Show(DockPane, DockState.DockLeft);
                FormProjectExplorer.Show(DockPane, DockState.DockLeft);
            }

            Messages.LogEngine("Welcome to Plato!", this);
            // Add docking pages
            

            //kryptonDockingManager.AddDockspace("Control1", DockingEdge.Left, new KryptonPage[] { NewInput(), NewInput() });
            //kryptonDockingManager.AddDockspace("Control1", DockingEdge.Bottom, new KryptonPage[] { NewInput(), NewInput() });
            //kryptonDockingManager.AddDockspace("Control2", DockingEdge.Bottom, new KryptonPage[] { NewInput(), NewInput() });
            //kryptonDockingManager.AddAutoHiddenGroup("Control2", DockingEdge.Right, new KryptonPage[] { NewInput(), NewInput() });
        }
        private IDockContent GetDockWindow(string typ)
        {
            if (typ == typeof(SceneExplorer).ToString()) return FormSceneExplorer;
            if (typ == typeof(ProjectExplorer).ToString()) return FormProjectExplorer;
            if (typ == typeof(SceneEditor).ToString()) return FormSceneEditor;
            if (typ == typeof(Messages).ToString()) return FormMessages;
            return null;
        }
        private void dockPanel4_ActiveContentChanged(object sender, EventArgs e)
        {

        }

        private void PlatoIDE_FormClosing(object sender, FormClosingEventArgs e)
        {
            DockPane.SaveAsXml("GuiLayout.xml");
        }


    }
}
